package com.zhike.api.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;

import com.zhike.common.enums.EnumUtils;
import com.zhike.common.enums.YesNoEnum;

import lombok.Data;

@Configuration
@ConfigurationProperties(prefix = "zkim")
@Data
public class ZkimConfig {
    /**
     * 版本开关
     */
    public static YesNoEnum ENABLED = YesNoEnum.NO;
    /**
     * 最低版本
     */
    public static String VERSION = "3.0.0";
    // 当前环境
    private String env;
    // 待部署域名
    private String domain;

    public void setEnabled(String enabled) {
        if (!StringUtils.hasLength(enabled)) {
            ZkimConfig.ENABLED = EnumUtils.toEnum(YesNoEnum.class, enabled, YesNoEnum.NO);
        }
    }

    public void setVERSION(String version) {
        if (!StringUtils.hasLength(version)) {
            ZkimConfig.VERSION = version;
        }
    }
}
